package com.chuhe.starry.service.adapter;

import cn.hutool.crypto.digest.DigestUtil;
import com.chuhe.common.domain.entity.UserInfo;
import com.chuhe.common.domain.enums.UserStatusEnum;
import com.chuhe.common.domain.vo.req.RegisterReq;

import java.util.Date;

/**
 * @Author: 楚河
 * @Date: 2025年05月11日12:31
 */
public class UserInfoAdapter {
    /**
     * 组装用户注册信息
     * @Author: 楚河
     * @Date: 2025-05-11 12:32
     */
    public static UserInfo buildRegisterInfo(RegisterReq registerReq, String userId) {
        Date curDate = new Date();
        UserInfo userInfo = new UserInfo();
        userInfo.setUserId(userId);
        userInfo.setNickName(registerReq.getNickName());
        userInfo.setEmail(registerReq.getEmail());
        userInfo.setPassword(DigestUtil.md5Hex(registerReq.getPassword().getBytes()));
        userInfo.setCreateTime(curDate);
        userInfo.setStatus(UserStatusEnum.ENABLE.getStatus());
        userInfo.setLastOffTime(curDate.getTime());
        return userInfo;
    }
}
